home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / src / dlgcomm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  6.0 KB  |  214 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12. #ifndef _DLGSH_INCLUDED_
  13. #include <dlgs.h>
  14. #endif
  15.  
  16. #ifdef AFX_AUX_SEG
  17. #pragma code_seg(AFX_AUX_SEG)
  18. #endif
  19.  
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. #define new DEBUG_NEW
  26.  
  27. #if defined(_WIN32_WCE)
  28. UINT _afxMsgLBSELCHANGE = 0;
  29. UINT _afxMsgSHAREVI = 0;
  30. UINT _afxMsgFILEOK = 0;
  31. UINT _afxMsgCOLOROK = 0;
  32. UINT _afxMsgHELP = 0;
  33. UINT _afxMsgSETRGB = 0;
  34. #else // _WIN32_WCE
  35. AFX_COMDAT UINT _afxMsgLBSELCHANGE = 0;
  36. AFX_COMDAT UINT _afxMsgSHAREVI = 0;
  37. AFX_COMDAT UINT _afxMsgFILEOK = 0;
  38. AFX_COMDAT UINT _afxMsgCOLOROK = 0;
  39. AFX_COMDAT UINT _afxMsgHELP = 0;
  40. AFX_COMDAT UINT _afxMsgSETRGB = 0;
  41. #endif // _WIN32_WCE
  42.  
  43. BEGIN_MESSAGE_MAP(CCommonDialog, CDialog)
  44.     //{{AFX_MSG_MAP(CCommonDialog)
  45.     ON_WM_HELPINFO()
  46.     //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48.  
  49. UINT CALLBACK
  50. _AfxCommDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  51. {
  52.     if (hWnd == NULL)
  53.         return 0;
  54.  
  55.     _AFX_THREAD_STATE* pThreadState = _afxThreadState.GetData();
  56. #if defined(_WIN32_WCE)
  57.     if(pThreadState->m_pWndInit != NULL)
  58.     {
  59.         // We need to do our MFC hooking stuff now.  Note: since
  60.         // wce_FirstDlgProc repumps the message, we'll get back here, but
  61.         // since wce_FirstDlgProc NULL's pThreadState->m_pWndInit, regular 
  62.         // processing of the message in this function will occur upon reentrancy. 
  63.         // Because *this* call (the first one) doesn't really count, we 
  64.         // return immediately with TRUE.  We assume that the OS-owned dialog
  65.         // procedure that called the hook _AfxCommDlgProc is treating the
  66.         // return value 1 as a "message processed, don't process further."
  67.         // We lose the return value of the "repumped message."
  68.         wce_FirstDlgProc(hWnd, message, wParam, lParam);
  69.         return 1; 
  70.     }
  71. #endif // _WIN32_WCE
  72.  
  73.     if (pThreadState->m_pAlternateWndInit != NULL)
  74.     {
  75.         ASSERT_KINDOF(CFileDialog,pThreadState->m_pAlternateWndInit);
  76.         pThreadState->m_pAlternateWndInit->SubclassWindow(hWnd);
  77.         pThreadState->m_pAlternateWndInit = NULL;
  78.     }
  79.     ASSERT(pThreadState->m_pAlternateWndInit == NULL);
  80.  
  81.     if (message == WM_INITDIALOG)
  82.     {
  83.         _afxMsgLBSELCHANGE = ::RegisterWindowMessage(LBSELCHSTRING);
  84.         _afxMsgSHAREVI = ::RegisterWindowMessage(SHAREVISTRING);
  85.         _afxMsgFILEOK = ::RegisterWindowMessage(FILEOKSTRING);
  86.         _afxMsgCOLOROK = ::RegisterWindowMessage(COLOROKSTRING);
  87.         _afxMsgHELP = ::RegisterWindowMessage(HELPMSGSTRING);
  88.         _afxMsgSETRGB = ::RegisterWindowMessage(SETRGBSTRING);
  89.         return (UINT)AfxDlgProc(hWnd, message, wParam, lParam);
  90.     }
  91.  
  92.     if (message == _afxMsgHELP ||
  93.        (message == WM_COMMAND && LOWORD(wParam) == pshHelp))
  94.     {
  95.         // just translate the message into the AFX standard help command.
  96.         SendMessage(hWnd, WM_COMMAND, ID_HELP, 0);
  97.         return 1;
  98.     }
  99.  
  100.     if (message < 0xC000)
  101.     {
  102.         // not a ::RegisterWindowMessage message
  103.         return 0;
  104.     }
  105.  
  106.     // assume it is already wired up to a permanent one
  107.     CDialog* pDlg = (CDialog*)CWnd::FromHandlePermanent(hWnd);
  108.     ASSERT(pDlg != NULL);
  109.     ASSERT_KINDOF(CDialog, pDlg);
  110.  
  111.     if (pDlg->IsKindOf(RUNTIME_CLASS(CFileDialog)))
  112.     {
  113.         // If we're exploring then we are not interested in the Registered messages
  114.         if (((CFileDialog*)pDlg)->m_ofn.Flags & OFN_EXPLORER)
  115.             return 0;
  116.     }
  117.  
  118.     // RegisterWindowMessage - does not copy to lastState buffer, so
  119.     // CWnd::GetCurrentMessage and CWnd::Default will NOT work
  120.     // while in these handlers
  121.  
  122.     // Dispatch special commdlg messages through our virtual callbacks
  123.     if (message == _afxMsgSHAREVI)
  124.     {
  125.         ASSERT_KINDOF(CFileDialog, pDlg);
  126.         return ((CFileDialog*)pDlg)->OnShareViolation((LPCTSTR)lParam);
  127.     }
  128.     else if (message == _afxMsgFILEOK)
  129.     {
  130.         ASSERT_KINDOF(CFileDialog, pDlg);
  131.  
  132.         if (afxData.bWin4)
  133.             ((CFileDialog*)pDlg)->m_pofnTemp = (OPENFILENAME*)lParam;
  134.  
  135.         BOOL bResult = ((CFileDialog*)pDlg)->OnFileNameOK();
  136.  
  137.         ((CFileDialog*)pDlg)->m_pofnTemp = NULL;
  138.  
  139.         return bResult;
  140.     }
  141.     else if (message == _afxMsgLBSELCHANGE)
  142.     {
  143.         ASSERT_KINDOF(CFileDialog, pDlg);
  144.         ((CFileDialog*)pDlg)->OnLBSelChangedNotify(wParam, LOWORD(lParam),
  145.                 HIWORD(lParam));
  146.         return 0;
  147.     }
  148. #if !defined(_WIN32_WCE_NO_COLORDLG)
  149.     else if (message == _afxMsgCOLOROK)
  150.     {
  151.         ASSERT_KINDOF(CColorDialog, pDlg);
  152.         return ((CColorDialog*)pDlg)->OnColorOK();
  153.     }
  154.     else if (message == _afxMsgSETRGB)
  155.     {
  156.         // nothing to do here, since this is a SendMessage
  157.         return 0;
  158.     }
  159. #endif // _WIN32_WCE_NO_COLORDLG
  160.     return 0;
  161. }
  162.  
  163. ////////////////////////////////////////////////////////////////////////////
  164. // CCommonDialog - common dialog helper class
  165.  
  166. void CCommonDialog::OnOK()
  167. {
  168.     ASSERT_VALID(this);
  169.  
  170.     if (!UpdateData(TRUE))
  171.     {
  172.         TRACE0("UpdateData failed during dialog termination.\n");
  173.         // the UpdateData routine will set focus to correct item
  174.         return;
  175.     }
  176.  
  177. #if defined(_WIN32_WCE)
  178. // WinCE: Give the "registered window message" processing a chance
  179.     if (IsKindOf(RUNTIME_CLASS(CFileDialog)))
  180.     {
  181.         if(_AfxCommDlgProc(m_hWnd, _afxMsgFILEOK, 0, (LPARAM)&((CFileDialog*)this)->m_ofn))
  182.             return;
  183.     }
  184. #if !defined(_WIN32_WCE_NO_COLORDLG)
  185.     else if (IsKindOf(RUNTIME_CLASS(CColorDialog)))
  186.     {
  187.         if(_AfxCommDlgProc(m_hWnd, _afxMsgCOLOROK, 0, 0))
  188.             return;
  189.     }
  190. #endif // _WIN32_WCE_NO_COLORDLG    
  191. #endif // _WIN32_WCE
  192.     // Common dialogs do not require ::EndDialog
  193.     Default();
  194. }
  195.  
  196. void CCommonDialog::OnCancel()
  197. {
  198.     ASSERT_VALID(this);
  199.  
  200.     // Common dialogs do not require ::EndDialog
  201.     Default();
  202. }
  203.  
  204. BOOL CCommonDialog::OnHelpInfo(HELPINFO*)
  205. {
  206.     return Default();
  207. }
  208.  
  209. ////////////////////////////////////////////////////////////////////////////
  210.  
  211. #if defined(_WIN32_WCE)
  212. // WinCE: we want runtime class information so we can use IsKindOf (wcewnd.cpp)
  213. IMPLEMENT_DYNAMIC(CCommonDialog, CDialog)
  214. #endif